package com.edu.app.service.impl.linkservices;

import com.edu.app.bean.core.SysActivity;
import com.edu.app.bean.core.SysCustomer;
import com.edu.app.bean.linkbeans.SysCustomerActivity;
import com.edu.app.bean.virtualbean.CustomerActivities;

import com.edu.app.mapper.linkmappers.SysCustomerActivityMapper;
import com.edu.app.service.impl.SysBaseServiceImpl;
import com.edu.app.service.sys.linkservices.SysCustomerActivityService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysCustomerActivityServiceImpl extends SysBaseServiceImpl<SysCustomerActivity,SysCustomerActivityMapper> implements SysCustomerActivityService {



    @Override
    public PageInfo getCustomerActivityByPage(Integer id, Integer currentPage, Integer pageSize) {
        //设置分页信息，分别是当前页数和每页显示的总记录数【记住：必须在mapper接口中的方法执行之前设置该分页信息】
        PageHelper.startPage(currentPage, pageSize, true);
        List<SysActivity> list = mapper.getCustomerActivityByPage(id);

        PageInfo<SysActivity> pageInfo = new PageInfo<SysActivity>(list);
        return pageInfo;
    }

    @Override
    public PageInfo getCustomerActivities(Integer id, String type, Integer currentPage, Integer pageSize) {
        //设置分页信息，分别是当前页数和每页显示的总记录数【记住：必须在mapper接口中的方法执行之前设置该分页信息】
        PageHelper.startPage(currentPage, pageSize, true);
        type = "%" + type + "%"; //change to like condition for getting 'S_LOV_SALES%' and 'S_LOV_LESSON'
        List<CustomerActivities> list = mapper.getCustomerActivities(id, type);
        PageInfo<CustomerActivities> pageInfo = new PageInfo<CustomerActivities>(list);
        return pageInfo;
    }

    @Override
    public PageInfo getCustomerActivitiesAll(Integer id, Integer currentPage, Integer pageSize) {
        //设置分页信息，分别是当前页数和每页显示的总记录数【记住：必须在mapper接口中的方法执行之前设置该分页信息】
        PageHelper.startPage(currentPage, pageSize, true);
        List<CustomerActivities> list = mapper.getCustomerActivitiesAll(id);
        PageInfo<CustomerActivities> pageInfo = new PageInfo<CustomerActivities>(list);
        return pageInfo;
    }

    @Override
    public List<SysActivity> getActivityByCustomerId(Integer id){

        List<SysActivity> sysActivityList = mapper.getActivityByCustomerId(id);
        return sysActivityList;
    }

    @Override
    public List<SysCustomer> getCustomerByActivityId(Integer id){

        List<SysCustomer> sysCustomerList = mapper.getCustomerByActivityId(id);
        return sysCustomerList;
    }

    @Override
    public SysCustomerActivity getCustomerActivity(Integer cutomer_id, Integer activity_id){
        return mapper.getCustomerActivity(cutomer_id, activity_id);
    }

    @Override
    public Integer deleteCustomerActivityByActivityId(Integer activity_id){
        return mapper.deleteCustomerActivityByActivityId(activity_id);
    }

    @Override
    public Integer deleteCustomerActivityByCustomerId(Integer customer_id){
        return mapper.deleteCustomerActivityByCustomerId(customer_id);
    }
}
